package com.easyJava.builder;

import com.easyJava.bean.Constants;
import com.easyJava.bean.FieldInfo;
import com.easyJava.bean.TableInfo;
import com.easyJava.utils.DateUtils;
import com.sun.xml.internal.ws.api.server.SDDocument;

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.Buffer;
import java.util.Date;

/**
 * 生成注释
 */
public class BuildComment {


    private static final String DESCRIPTION = "Description:";


    private static final String AUTHOR = "author:";

    private static final String DATE = "date:";


    public static final String ACCORDING = "根据";

    /**
     * 类注释
     * @param bw
     * @return
     */
    public static void ClassComment(BufferedWriter bw, TableInfo tableInfo) throws IOException {
         /**
         * Description:
         * author:wanghui
         * date:
         */
        bw.write("/**");
        bw.newLine();
        bw.write("* "+ DESCRIPTION + tableInfo.getComment());
        bw.newLine();
        bw.write("* "+AUTHOR+ Constants.AUTHOR_NAME );
        bw.newLine();
        bw.write("* "+ DATE + DateUtils.format(new Date(),DateUtils._YYYYMMDD));
        bw.newLine();
        bw.write("*/");
        bw.newLine();
    }

    /**
     * 字段注释
     * @param bw
     */
    public static void FieldComment(BufferedWriter bw, FieldInfo fieldInfo) throws IOException {
        bw.write("\t/**");
        bw.newLine();
        bw.write("\t*"+ fieldInfo.getComment());
        bw.newLine();
        bw.write("\t*/");
        bw.newLine();
    }


    /**
     * mapper方法注释
     */
    public static void mapperMethodComment(String action , String methodName,BufferedWriter bw) throws IOException {
        bw.write("\t/**");
        bw.newLine();
        bw.write("\t*  "+ ACCORDING + methodName + action);
        bw.newLine();
        bw.write("\t*/");
        bw.newLine();
    }


    /**
     *  方法注释
     * @param bw
     */
    public static void MethodComment(BufferedWriter bw){

    }
}
